﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LevelManager : MonoBehaviour
{
    public static LevelManager Instance;
    private void Awake()
    {
        if (Instance != null && Instance != this)
        {
            Destroy(gameObject);
            return;

        }
        Instance = this;
        //DontDestroyOnLoad(gameObject);
    }

    public List<int> Npcs = new List<int>();

    private int _levelIndex = 0;
    private int _currentNpcCount = 0;
    public Action OnGameFinish;

    public void ResetLevel(int levelIndex)
    {
        _currentNpcCount = 0;
        _levelIndex = levelIndex;
    }

    public bool Finish 
    {
        get 
        {
            if (_currentNpcCount >= Npcs[_levelIndex - 1]) 
            {
               OnGameFinish?.Invoke();
                return true;
            }
            return false;
        }
    }

    public void GetNPC() 
    {
        _currentNpcCount++;
        Debug.Log("捕获npc："+_currentNpcCount);
    }
}
